# encoding: utf-8

import urllib, urllib.parse, urllib.request, webbrowser, time

def post(url, data):
	data=urllib.parse.urlencode(data)
	req=urllib.request.urlopen(url,data)
	info=req.info()
	size=int(info.get('Content-Length'))
	response="response.html"
	f=open(response,'wb')
	data=req.read(1024)
	progress=0
	while(len(data)):
		f.write(data)
		progress+=len(data)
		print("处理中...%.2f%%"%(progress*100.0/size,))
		data=req.read(1024)
		time.sleep(0.01)
	req.close()
	f.close()
	print("完成")
	webbrowser.open(response)

if __name__=="__main__":
	req=urllib.request.urlopen(url='http://www.twitter.com')
	info=req.info()
	print(info)
	req.close()
